package com.yangrd.airship.upms.domain;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * description: Dict
 *
 * @author: yangrd
 * @date: 2021/7/3
 * @version: 1.0
 */
@Getter
@Setter
@Entity
@Table(name = "upms_dict")
public class Dict extends AbstractEntity {

    String keyword;

    String name;

    @ElementCollection(fetch = FetchType.EAGER)
    @OrderBy(" sort asc")
    @CollectionTable(name = "upms_dict_item")
    List<DictItem> items ;

    public void addItem(DictItem item){
        if(Objects.isNull(items)){
            items = new ArrayList<>();
        }
        items.add(item);
    }
}
